<?php

namespace App\WebSocket;

use Swoole\WebSocket\Server;

class WebSocketHandler
{

    public function onOpen(Server $server, $request) {
        $server->push($request->fd, '连接成功');
    }

    public function onMessage(Server $server, $frame) {
        $server->push($frame->fd, "收到消息: {$frame->data}");
    }

    public function onClose(Server $server, $fd) {
        // 处理连接关闭
    }
}
